﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace LedControl
{
    public partial class Form1 : Form
    {        
        int tp3DemoIndex;    
        private void tp3Demo_Click(object sender, EventArgs e)
        {
            tp3DemoIndex = 1;
            tp3DemoTimer.Enabled = true;
            tp3Case_Click(this.tp3Case1, null);            
        }
        private void button31_Click(object sender, EventArgs e)
        {
            drawPic.DrawScreen(new double[11]);
            tp3NeutralCaseTimer.Enabled = false;
            tp3DemoTimer.Enabled = false;
            textBox2.Text = "30";
            textBox2.ReadOnly = false;
        }
        private void tp3NeutralCaseTimer_Tick(object sender, EventArgs e)
        {
            NeutralCaseTime--;
            textBox2.Text = NeutralCaseTime.ToString();
            if (NeutralCaseTime == 0)
            {
                textBox2.Text = "30";
                textBox2.ReadOnly = false;
                tp3NeutralCaseTimer.Enabled = false;
            }
        }  
        private void tb3NeutralCase_Click(object sender, EventArgs e)
        {
            NeutralCaseTime = Convert.ToInt32(textBox2.Text);
            textBox2.ReadOnly = true;
            tp3NeutralCaseTimer.Enabled = true;
            double[] Leds = new double[11];
            Leds[0] = 152;
            Leds[1] = 99;
            Leds[2] = 78;
            Leds[3] = 0;
            Leds[4] = 54;
            Leds[5] = 166;
            Leds[6] = 107;
            Leds[7] = 107;
            Leds[8] = 70;
            Leds[9] = 0;
            Leds[10] = 94;
            tbCCT1.Text = "5003±50";
            tbLuminance1.Text = "50±1";
            tbX1.Text = "0.346±0.005";
            tbY1.Text = "0.359±0.005";
            drawPic.DrawScreen(Leds);
        }      
            
        private void tp3Case_Click(object sender, EventArgs e)
        {
            Button bt = (Button)sender;
            double[] Leds = new double[11];
            switch (bt.Text)
            {
                case "(1) D65-1":
                    Leds[0] = 225;
                    Leds[1] = 180;
                    Leds[2] = 0;
                    Leds[3] = 100;
                    Leds[4] = 0;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(2) D65-2":
                    Leds[0] = 238;
                    Leds[1] = 160;
                    Leds[2] = 0;
                    Leds[3] = 60;
                    Leds[4] = 98;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(3) D65-3":
                    Leds[0] = 239;
                    Leds[1] = 156;
                    Leds[2] = 0;
                    Leds[3] = 48;
                    Leds[4] = 133;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(4) D65-4":
                    Leds[0] = 218;
                    Leds[1] = 181;
                    Leds[2] = 0;
                    Leds[3] = 105;
                    Leds[4] = 163;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(5) D65-5":
                    Leds[0] = 223;
                    Leds[1] = 172;
                    Leds[2] = 0;
                    Leds[3] = 93;
                    Leds[4] = 185;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(6) D50-1":
                    Leds[0] = 0;
                    Leds[1] = 201;
                    Leds[2] = 0;
                    Leds[3] = 126;
                    Leds[4] = 57;
                    Leds[5] = 230;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(7) D50-2":
                    Leds[0] = 0;
                    Leds[1] = 199;
                    Leds[2] = 0;
                    Leds[3] = 124;
                    Leds[4] = 102;
                    Leds[5] = 231;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(8) D50-3":
                    Leds[0] = 242;
                    Leds[1] = 144;
                    Leds[2] = 0;
                    Leds[3] = 77;
                    Leds[4] = 109;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(9) D50-4":
                    Leds[0] = 244;
                    Leds[1] = 137;
                    Leds[2] = 0;
                    Leds[3] = 69;
                    Leds[4] = 135;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(10) D50-5":
                    Leds[0] = 224;
                    Leds[1] = 167;
                    Leds[2] = 0;
                    Leds[3] = 114;
                    Leds[4] = 160;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(11) D40-1":
                    Leds[0] = 0;
                    Leds[1] = 196;
                    Leds[2] = 0;
                    Leds[3] = 141;
                    Leds[4] = 22;
                    Leds[5] = 229;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(12) D40-2":
                    Leds[0] = 230;
                    Leds[1] = 159;
                    Leds[2] = 0;
                    Leds[3] = 125;
                    Leds[4] = 30;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(13) D40-3":
                    Leds[0] = 219;
                    Leds[1] = 172;
                    Leds[2] = 0;
                    Leds[3] = 139;
                    Leds[4] = 92;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(14) D40-4":
                    Leds[0] = 255;
                    Leds[1] = 91;
                    Leds[2] = 0;
                    Leds[3] = 68;
                    Leds[4] = 104;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(15) D40-5":
                    Leds[0] = 254;
                    Leds[1] = 89;
                    Leds[2] = 0;
                    Leds[3] = 72;
                    Leds[4] = 126;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(16) A-1":
                    Leds[0] = 0;
                    Leds[1] = 210;
                    Leds[2] = 222;
                    Leds[3] = 0;
                    Leds[4] = 0;
                    Leds[5] = 142;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 168;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(17) A-2":
                    Leds[0] = 0;
                    Leds[1] = 171;
                    Leds[2] = 74;
                    Leds[3] = 0;
                    Leds[4] = 0;
                    Leds[5] = 241;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 198;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(18) A-3":
                    Leds[0] = 221;
                    Leds[1] = 137;
                    Leds[2] = 0;
                    Leds[3] = 137;
                    Leds[4] = 0;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(19) A-4":
                    Leds[0] = 247;
                    Leds[1] = 81;
                    Leds[2] = 165;
                    Leds[3] = 135;
                    Leds[4] = 45;
                    Leds[5] = 0;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
                case "(20) A-5":
                    Leds[0] = 0;
                    Leds[1] = 157;
                    Leds[2] = 0;
                    Leds[3] = 150;
                    Leds[4] = 108;
                    Leds[5] = 248;
                    Leds[6] = 0;
                    Leds[7] = 0;
                    Leds[8] = 0;
                    Leds[9] = 0;
                    Leds[10] = 0;
                    tbCCT1.Text = "5315±50";
                    tbLuminance1.Text = "70±1";
                    tbX1.Text = "0.337±0.005";
                    tbY1.Text = "0.350±0.005";
                    break;
            }
            drawPic.DrawScreen(Leds);
        }
        private void tp3DemoTimer_Tick(object sender, EventArgs e)
        {
            tp3DemoIndex++;
            switch (tp3DemoIndex)
            {
                case 2:
                    tp3Case_Click(this.tp3Case2, null);
                    break;
                case 3:
                    tp3Case_Click(this.tp3Case3, null);
                    break;
                case 4:
                    tp3Case_Click(this.tp3Case4, null);
                    break;
                case 5:
                    tp3Case_Click(this.tp3Case5, null);
                    break;
                case 6:
                    tp3Case_Click(this.tp3Case6, null);
                    break;
                case 7:
                    tp3Case_Click(this.tp3Case7, null);
                    break;
                case 8:
                    tp3Case_Click(this.tp3Case8, null);
                    break;
                case 9:
                    tp3Case_Click(this.tp3Case9, null);
                    break;
                case 10:
                    tp3Case_Click(this.tp3Case10, null);
                    break;
                case 11:
                    tp3Case_Click(this.tp3Case11, null);
                    break;
                case 12:
                    tp3Case_Click(this.tp3Case12, null);
                    break;
                case 13:
                    tp3Case_Click(this.tp3Case13, null);
                    break;
                case 14:
                    tp3Case_Click(this.tp3Case14, null);
                    break;
                case 15:
                    tp3Case_Click(this.tp3Case15, null);
                    break;
                case 16:
                    tp3Case_Click(this.tp3Case16, null);
                    break;
                case 17:
                    tp3Case_Click(this.tp3Case17, null);
                    break;
                case 18:
                    tp3Case_Click(this.tp3Case18, null);
                    break;
                case 19:
                    tp3Case_Click(this.tp3Case19, null);
                    break;
                case 20:
                    tp3Case_Click(this.tp3Case20, null);
                    break;
                case 21://完成Demo循环
                    tp3Demo.Enabled = false;
                    break;
            }
        }
    }
}
